﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PRE.catalog
{
    public partial class FrmPhieusudungdichvu_thanhtoan : PRE.catalog.FrmBase
    {
        DAL.PhieusudungdichvuDAL _dal = new DAL.PhieusudungdichvuDAL();
        BLL.PhieusudungdichvuBLL _bll = new BLL.PhieusudungdichvuBLL();
        public FrmPhieusudungdichvu_thanhtoan()
        {
            InitializeComponent();
        }

        #region Override

        /// <summary>
        /// Perform when click add button
        /// </summary>
        protected override void PerformAdd()
        {

            


            base.PerformAdd();
        }

        /// <summary>
        /// Perform when click cancel button
        /// </summary>
        ///protected override void PerformCance()
        //{
        //   // PerformRefresh();
        //    base.PerformCancel();
        //}
        /// <summary>
        /// Perform when click delete button
        /// </summary>
        /// <returns></returns>
        protected override void PerformDelete()
        {
           

            base.PerformDelete();
        }

        /// <summary>
        /// Perform when click edit button
        /// </summary>
        protected override void PerformEdit()
        {

            base.PerformEdit();
        }

        /// <summary>
        /// Perform when click print button
        /// </summary>
        protected override void PerformPrint()
        {
            string id = (grvMain.GetFocusedRowCellValue("MADICHVU") + "").Trim();
            DateTime ngay = Convert.ToDateTime(grvMain.GetFocusedRowCellValue("NGAYKHAM"));
            string stt = (grvMain.GetFocusedRowCellValue("STTPHIEU") + "").Trim();
            DataTable dtb_report = _dal.Select_Report(id, ngay, stt);

            var frm = new Report.Report_Base();
            var xr = new Report.XRPhieusudungdichvu();

            xr.DataSource = dtb_report;
            frm.SetReport(xr);

            frm.Show();

            base.PerformPrint();
        }

        /// <summary>
        /// Load data or perform when click refresh button
        /// </summary>
        protected override void PerformRefresh()
        {
            ReadOnlyControl();
            LoadData();

            if (_dtb != null)
            {
                // Binding data
                ClearDataBindings();
                if (_dtb.Rows.Count > 0) DataBindingControl();
            }

            base.PerformRefresh();
        }

        /// <summary>
        /// Perform when click save button
        /// </summary>
        protected override void PerformSave()
        {
            // var name = Proper(txtHoten.Text);
            //var address = Proper(txtDiachi.Text);

           

            base.PerformSave();
        }

        /// <summary>
        /// Reset all input control
        /// </summary>
        protected override void ResetText()
        {

        }

        /// <summary>
        /// Clear data binding
        /// </summary>
        protected override void ClearDataBindings()
        {


            base.ClearDataBindings();
        }

        /// <summary>
        /// Add data binding
        /// </summary>
        protected override void DataBindingControl()
        {
          
            base.DataBindingControl();
        }

        /// <summary>
        /// Set read only control on form
        /// </summary>
        /// <param name="isReadOnly">Read only is trule else normal</param>
        protected override void ReadOnlyControl(bool isReadOnly = true)
        {
    

            grcMain.Enabled = isReadOnly;

            base.ReadOnlyControl(isReadOnly);
        }

        protected override void PerformSearch()
        {
            base.PerformSearch();
        }

        /// <summary>
        /// Update object
        /// </summary>
        /// <returns>True if successful else false</returns>
        protected override bool UpdateObject()
        {
            return base.UpdateObject();
        }

        /// <summary>
        /// Insert object
        /// </summary>
        /// <returns>True if successful else false</returns>
        protected override bool InsertObject()
        {
            return base.InsertObject();
        }

        /// <summary>
        /// Load data
        /// </summary>
        protected override void LoadData()
        {
            ////DataTable tmp = _dal3.Select_Current(DateTime.Now);
            ////string _makhoa = tmp.Rows[0]["Makhoa"] + "";
            //var o = new DAL.Entities.phieusudungdichvu()
            //{
            //    sttphieu = _sttphieu1.Trim(),
            //    ngaykham = Convert.ToDateTime(_ngaykham1.Trim())
            //};
            _dtb = _dal.Select();

            if (_dtb != null)
            {
                grcMain.DataSource = _dtb;
            }

            base.LoadData();
        }
        #endregion

        private void FrmPhieusudungdichvu_thanhtoan_Load(object sender, EventArgs e)
        {
            ChangeStatus_PhieuSDDV1();
            PerformRefresh();
        }
    }
}
